package com.coco.service.impl;

import com.coco.dao.CollectionMapper;
import com.coco.model.CollectionCondition;
import com.coco.model.VideoModel;
import com.coco.service.CollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @author GHOSTLaycoo
 * @date 2020/4/26 - 9:54
 */
@Service
public class CollectionServiceImpl implements CollectionService{

    @Autowired
    private CollectionMapper collectionMapper;

    @Override
    public int saveCollection(CollectionCondition collectionCondition) {
        String id = UUID.randomUUID().toString();
        Date date = new Date();
        collectionCondition.setCreateTime(date);
        collectionCondition.setId(id);
        int i = collectionMapper.saveCollection(collectionCondition);
        return i;
    }

    @Override
    public int deleteCollection(CollectionCondition collectionCondition) {
        int i = collectionMapper.deleteCollection(collectionCondition);
        return i;
    }

    @Override
    public int selectCollection(CollectionCondition collectionCondition) {
        int i = collectionMapper.selectCollection(collectionCondition);
        return i;
    }

    @Override
    public List<VideoModel> selectCollectionByUserId(String userId) {
        List<VideoModel> videoModels = collectionMapper.selectCollectionByUserId(userId);
        return videoModels;
    }
}
